<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>dc-example</title>
    <script src="/libs/dc-sdk/dc.min.js"></script>
    <script src="../turf.min.js"></script>
    <link href="/libs/dc-sdk/dc.min.css" type="text/css" rel="stylesheet" />
    <link href="../index.css" type="text/css" rel="stylesheet" />
  </head>

  <body>
    <div id="viewer-container" class="viewer-container"></div>
    <script>
      DC.config.baseUrl = '../libs/dc-sdk/resources/'
      DC.registerLib('turf', turf)
      let viewer = new DC.Viewer('viewer-container')

      viewer.setOptions({
        enableFxaa: true,
      })
      let baseLayer = DC.ImageryLayerFactory.createImageryLayer(
        DC.ImageryType.AMAP,
        {
          style: 'img',
          crs: 'WGS84',
        }
      )
      viewer.addBaseLayer(baseLayer)
      let layer = new DC.VectorLayer('layer')
      viewer.addLayer(layer)
      let polygon = new DC.Polygon(
        '120.71259021075333,31.22148081085083;120.71611354431036,31.221447256684566;120.7140691869497,31.21875584696343'
      )
      polygon.setStyle({
        material: DC.Color.YELLOW,
      })
      layer.addOverlay(polygon)
      let coords = DC.GeoTools.transformPolygonRotate(
        '120.71259021075333,31.22148081085083;120.71611354431036,31.221447256684566;120.7140691869497,31.21875584696343',
        45
      )
      polygon = new DC.Polygon(coords)
      polygon.setStyle({
        zIndex: 1,
        material: DC.Color.RED.withAlpha(0.5),
      })
      layer.addOverlay(polygon)
      viewer.flyTo(layer)
    </script>
  </body>
</html>
